<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>
<style>
    html,
    body {
        background-color: #fff;
    }

    .placeholder_div {
        background-color: #fbf9f9;
    }

    .main {
        padding: 1rem;
        background-color: #fff;
    }

    .item {
        width: 100%;
        height: 7.5rem;
        box-shadow: 0 0.1rem 0.5rem 0.1rem #eee;
        margin-bottom: 1rem;
        border-radius: 1rem;

    }

    .item div {
        padding: 0.8rem;
        font-size: 0.6rem;
        color: #838383;
    }

    .item div .item_title {
        font-size: 0.7rem;
        color: #303030;
    }

    .item div .item_title span {
        margin-left: 1rem;
    }

    .item .symptom {
        font-size: 0.7rem;
        color: #303030;
        margin-top: 0.5rem;
    }

    .item .prescription {
        margin: 0.25rem 0 0.75rem 0;
    }

    .item .chat {
        float: right;
        color: #2E8EFF;
        width: 2.5rem;
        height: 1rem;
        background-color: #F2F2F2;
        font-size: 0.5rem;
        text-align: center;
        line-height: 1.1rem;
        border-radius: 0.2rem;
        margin-top: -0.9rem;
    }
</style>

<body>
    <div  id="app" v-cloak>
        <div class="placeholder_div"></div>

        <div class="gerenyian main">
            <div class="item" v-for="item in bingli_list">
                <div>
                    <p class="item_title">{{item.name}}
                        <span v-if="item.sex == 1">男</span>
                        <span v-if="item.sex == 2">女</span>
                        <span>{{item.age}}岁</span>
                    </p>
                    <p class="chat">{{item.dosageForm}}</p>
                    <p class="symptom">{{item.diseases}}</p>
                    <p class="prescription">{{item.prescription}}</p>
                    <p class="time">{{item.createTimeText}}</p>
                </div>
            </div>


        </div>

    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();
        get_data()

        //上拉加载
        api.addEventListener({
            name: 'scrolltobottom',
            extra: {
                threshold: 20 //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function (ret, err) {
            app.page++
            get_data()
        });
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            page: 1,
            bingli_list: [],
        },
        methods: {

        },

    })

    function get_data() {
        get_ajax("prescribe/plan/list-user-page", {
            userId: api.pageParam.id,
            page: app.page,
            pagesize: 10,
        }, function (res, err) {
            if (res.code == 200) {
              if(res.data.data){
                if(app.page == 1){
                  app.bingli_list = res.data.data
                }else{
                  app.bingli_list = app.bingli_list.concat(res.data.data)
                }
              }else {
                  toast("已经没有数据了！")
              }
            }
        })
    }
</script>
